﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CodeDynamiksEngine;
using MESCodeFile;
using LiveNotificationSystem;

namespace mes_tublay
{
    public partial class frmRemarksdisplay : Form
    {
        frmTreasuryeBPLS x;
        public frmRemarksdisplay(frmTreasuryeBPLS p)
        {
            x = p;
            InitializeComponent();
            this.Load += new EventHandler(frmRemarksdisplay_Load);
            btnok.Click += new EventHandler(btnok_Click);
        }

        void btnok_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        void frmRemarksdisplay_Load(object sender, EventArgs e)
        {
            string ap = x.appno;
            lblappnum.Text = ap;

            CodeScript s = new CodeScript("DISPLAYREMARKS");
            s.Add(CodeIns.DBU_NEW_CORE);
            s.Add(CodeIns.DBU_CONNECT, Common.CFG.Read("DRIVER"), Common.CFG.Read("DB"),
                        Common.CFG.Read("UID"), Common.CFG.Read("PWD"), Common.CFG.Read("SERVER"));
            s.Add(CodeIns.DBU_QUERY, "Select fRemark as REMARK, fOfficer as TREASURER from tblremarks where fApplicationNumber='" + ap + "' AND fOffice='TREASURY_DEPT_TREASURER' order by fID desc");
            s.Add(CodeIns.DBU_END);

            CodeProcessor p = new CodeProcessor(ThreadingMode.Exclusive);
            p.ProcessCompleted += new EventHandler(delegate
            {
                p.SafeCall(this, delegate
                {
                    if (p.State == ProcessorFlag.DataRdyErr ||
                        p.State == ProcessorFlag.Error ||
                        p.State == ProcessorFlag.ReadyErr)
                    {
                        Confirm.Error("Sampler", p.GetProcessorMessage);
                        return;
                    }
                    DataCache r;
                    p.DataFetch(out r);
                    r.SetActivePage(0);
                    gridremarks.DataSource = r.ExportPage();
                    gridremarks.Columns[1].Width = (int)((float)gridremarks.Width * 0.3f);
                });
            });
            p.Run(s);
        }
    }
}
             
